package mysql

import "gorm.io/gorm"

type Order struct {
	gorm.Model
	UserId  int     `gorm:"type:int;not null;comment:'用户Id'"`
	GoodId  int     `gorm:"type:int;not null;comment:'商品Id'"`
	OrderSn string  `gorm:"type:varchar(100);unique;not null;comment:'订单编号'"`
	Amount  float64 `gorm:"type:double(10,2);not null;comment:'商品总价'"`
	PayType int     `gorm:"type:int;not null;comment:订单状态:1支付宝,2微信"`
	Status  int     `gorm:"type:int;not null;comment:订单状态:1已支付,2未支付,3待支付,4已完成"`
}

func (o *Order) GetOrder(id int) error {
	return DB.Where("id = ?", id).Limit(1).Find(&o).Error
}

func (o *Order) Create() error {
	return DB.Create(&o).Error
}
